// 管理端积分礼包接口（axios 版），与 api.json 对齐
import http from './http'
import type {
  PointPack,
  PointPackListData,
  CreateAdminPointPackDto,
  UpdateAdminPointPackDto,
  PointPackIdData,
} from '@/types/point-pack.api'

/** 获取积分礼包列表（无需认证） */
export async function listPointPacks(params?: {
  name?: string
  status?: string
}): Promise<ApiResponse<PointPackListData>> {
  return http.get<PointPackListData>('/admin/point-pack', {
    params,
  })
}

/** 获取积分礼包详情（无需认证） */
export async function getPointPackDetail(id: string): Promise<ApiResponse<PointPack>> {
  return http.get<PointPack>(`/admin/point-pack/${id}`)
}

/** 创建积分礼包（JWT required） */
export async function createPointPack(
  dto: CreateAdminPointPackDto,
): Promise<ApiResponse<PointPackIdData>> {
  return http.post<CreateAdminPointPackDto, PointPackIdData>('/admin/point-pack', dto)
}

/** 更新积分礼包（JWT required） */
export async function updatePointPack(
  id: string,
  dto: UpdateAdminPointPackDto,
): Promise<ApiResponse<PointPackIdData>> {
  return http.patch<UpdateAdminPointPackDto, PointPackIdData>(`/admin/point-pack/${id}`, dto)
}

/** 删除积分礼包（JWT required） */
export async function deletePointPack(id: string): Promise<ApiResponse<PointPackIdData>> {
  return http.del<PointPackIdData>(`/admin/point-pack/${id}`)
}
